


capture log close
log using PSRM_Aid_FDI_Personalism_Cleaning-stata.log, replace
set more off


********************************************************************************
*                                                                              * 
* Foreign Aid, FDI and the Personalization of Power in Autocracies             *
* Bernat Puertas* and Abel Escribà-Folch*+                                     *
* *Universitat Pompeu Fabra                                                    *
* +Institut Barcelona d'Estudis Internacionals                                 *
* Contact: bernat.puertas@upf.edu                                              *
*                                                                              *  
********************************************************************************


cd "E:\UNIVERSITAT\PHD\PHD\PAPERS\PAPER - AID - FDI\SUBMISSIONS\PSRM\PSRM REPLICATION MATERIALS"


** CLEANING OF DIFFERENT DATASETS **



***** AIDDATA PROJECT ******

import delimited "AidData Project_noCOW.csv"


sort recipient year 
order year recipient cowcode
drop v1  

* Add cowcodes to Serbia *

replace cowcode = "345" in 1260239/1273886

* Add cowcodes to USSR *

replace cowcode = "365" in 1323009/1323028

* Add cowcodes to Yugoslavia *

replace cowcode = "345" in 1532554/1532751


export delimited "AidData Project_COW.csv", replace

clear

***** WDI *****


import delimited "WDI_noCOW.csv"

* Add cowcode to Serbia

 replace v13 = "345" in 8570/8620
 
export delimited "WDI_COW.csv", replace

clear



***** ROSS *****

import delimited "Ross_noCOW.csv"


* Czechoslovakia *

replace cowcode = "315" in 3653/3735

* RDA * 
replace cowcode = "265" in 5396/5478

* Serbia *
replace cowcode = "345" in 11787/11869

* South Vietnam  *
replace cowcode = "817" in 12617/12699
  
 * South Yemen *
replace cowcode = "680" in 15107/15189

* USSR *  
replace cowcode = "365" in 12700/12782
  
* North Yemen*
replace cowcode = "678" in 15024/15106
   
* Yugoslavia *
replace cowcode = "345" in 15273/15355

* North Vietnam *   
replace cowcode = "816" in 10293/10375


export delimited "Ross_COW.csv", replace

clear


log close


* The End
